<?php
require_once('../Connections/mlu.php'); 

require('table.php');
$pdf=new TABLE();
$pdf->SetFont('Arial','B',18);
$pdf->AddPage();

//				PARTE DEL TESTO INIZIALE
$html='<p ALIGN="center">CENTRO CULTURALE PIERGIORGIO FRASSATI - BRESCIA<br><br>MEETING DEL LIBRO USATO 2012</p>';
//$pdf->SetLeftMargin(50);
$pdf->SetXY(15,0);
$pdf->WriteHTML($html);
$pdf->SetLeftMargin(5);
$pdf->Ln();


$query="select * from ordini where data=date(now())";
 $Result1 = mysql_query($query, $mlu) or die(mysql_error());
  $pdf->Ln();
  $pdf->SetFont('Arial','',10);
 $html='<table border="1"><tr><td width=\'200\'>Ordine</td><td width=\'200\'>Numero Libri</td><td width=\'200\'>Prezzo di vendita</td><td width=\'200\'>Offerta</td></tr>';
	$totlibri=$totven=$totoff=0;
  while ($row_Recordset1 = mysql_fetch_assoc($Result1))
  {
	  $ordine=$row_Recordset1['idordine'];
	  $query="select count(*) as conto from ordini join carrelli using (idordine) where idordine=".$ordine;
	  $Result2 = mysql_query($query, $mlu) or die(mysql_error());
	  $row_Recordset2 = mysql_fetch_assoc($Result2);
	  $conto=$row_Recordset2['conto'];
	  $totlibri=$totlibri+$conto;
	  $query="select * from movimenti where tipo='v".$ordine."'";
	  $Result3 = mysql_query($query, $mlu) or die(mysql_error());
	  $row_Recordset3 = mysql_fetch_assoc($Result3);
	  $prezzovendita=$row_Recordset3['prezzo'];
	  $totven=$totven+$prezzovendita;
	  $query="select * from movimenti where tipo='o".$ordine."'";
	  $Result3 = mysql_query($query, $mlu) or die(mysql_error());
	  $row_Recordset3 = mysql_fetch_assoc($Result3);
	  $prezzoofferta=$row_Recordset3['prezzo'];
	  $totoff=$totoff+$prezzoofferta;
	  $html=$html.'<tr><td width=\'200\'>'.$ordine.'</td><td width=\'200\'>'.$conto.'</td><td width=\'200\'>'.$prezzovendita.'</td><td width=\'200\'>'.$prezzoofferta.'</td></tr>';
	 } 
$html=$html.'</table>';

$pdf->WriteHTML($html);

$pdf->SetFont('Arial','B',14);
$html='<p>Saldo totale del giorno '.date('d-m-Y').'</p>';
$pdf->WriteHTML($html);
$pdf->SetFont('Arial','',10);
$pdf->SetLeftMargin(5);
$pdf->Ln();
$html='<table><tr><td width=\'300\'>Totale libri venduti: '.$totlibri.'</td><td width=\'300\'>Totale prezzo di vendita: '.$totven.'</td><td width=\'300\'>Totale offerta: '.$totoff.'</td></tr></table>';
$pdf->WriteHTML($html);




$pdf->Output();
?>

